﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="InventoryManagementSystem.PurchasePage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:InventoryManagementSystem"
    xmlns:common="using:InventoryManagementSystem.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:converter="using:Infrastructure.Converter"
    mc:Ignorable="d"
    Loaded="page_Loaded">
    <common:LayoutAwarePage.Resources>
        <converter:DecimalToStringConverter x:Key="DecimalToStringConverter"/>
    </common:LayoutAwarePage.Resources>
    <Grid Style="{StaticResource LayoutRootStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
            <TextBlock x:Name="pageTitle" Grid.Column="1" Text="进货" Style="{StaticResource PageHeaderTextStyle}"/>
            <StackPanel Grid.Column="2" Orientation="Horizontal" Margin="0, 0, 0, 20" HorizontalAlignment="Right" VerticalAlignment="Bottom">
                <Button BorderThickness="0" Click="scanBarCode_Click">
                    <StackPanel>
                        <Path Stretch="Uniform" Fill="#FFFFFFFF" Width="64" Height="64" Data="M0,48.221001C0.42187881,48.4034,0.88282108,48.512703,1.3724532,48.512703L42.810287,48.512703C43.299792,48.512703,43.760795,48.4034,44.183997,48.221001L43.497794,51.833C43.497794,52.5882,42.883185,53.203999,42.122779,53.203999L2.0599594,53.203999C1.3006721,53.203999,0.6875062,52.5882,0.68750572,51.833z M23.906834,34.223999L31.549031,34.223999 37.044,43.581001 21.160999,43.581001z M12.19531,32.963486C11.584605,32.963486,11.411603,33.400982,10.927199,34.071472L4.2850688,44.21994C4.2850688,44.83173,4.7784834,45.324024,5.3892088,45.324024L22.089899,45.324024 38.790549,45.324024C39.401256,45.324024,39.898761,44.83173,39.898761,44.21994L33.2555,34.071472C32.772395,33.400982,32.599294,32.963486,31.987189,32.963486L22.089899,32.963486z M9.8151485,31.875L22.089899,31.875 34.36741,31.875C35.127917,31.875,35.340018,32.421894,35.943025,33.249981L44.183997,45.839619C44.183997,46.597507,43.567893,47.211998,42.810287,47.211998L22.089899,47.211998 1.3724532,47.211998C0.61462975,47.211998,0,46.597507,0,45.839619L8.2407948,33.249981C8.8397999,32.421894,9.0558719,31.875,9.8151485,31.875z M9.6149019,0L22.089992,0 34.5678,0C35.328399,0,35.943,0.61462402,35.943,1.37366L35.943,29.3046C35.943,30.0625,35.328399,30.677,34.5678,30.677L22.089992,30.677 9.6149019,30.677C8.8557507,30.677,8.2410003,30.0625,8.2410001,29.3046L8.2410001,1.37366C8.2410003,0.61462402,8.8557507,0,9.6149019,0z"/>
                        <TextBlock TextAlignment="Center">扫描条码</TextBlock>
                    </StackPanel>
                </Button>
                <Button BorderThickness="0" Click="createBarCode_Click">
                    <StackPanel>
                        <Path Stretch="Uniform" Fill="#FFFFFFFF" Width="64" Height="64" Data="M59.706001,9.5367432E-07L62.289001,9.5367432E-07 62.289001,36.134999 59.706001,36.134999z M50.609001,9.5367432E-07L52.086001,9.5367432E-07 52.086001,36.134999 50.609001,36.134999z M48.049002,9.5367432E-07L49.526001,9.5367432E-07 49.526001,36.134999 48.049002,36.134999z M42.078001,9.5367432E-07L44.570002,9.5367432E-07 44.570002,36.134999 42.078001,36.134999z M34.560001,9.5367432E-07L36.036001,9.5367432E-07 36.036001,36.134999 34.560001,36.134999z M24.617001,9.5367432E-07L26.094002,9.5367432E-07 26.094002,36.134999 24.617001,36.134999z M18.708,9.5367432E-07L20.185001,9.5367432E-07 20.185001,36.134999 18.708,36.134999z M16.148003,9.5367432E-07L17.625,9.5367432E-07 17.625,36.134999 16.148003,36.134999z M11.841,9.5367432E-07L14.057003,9.5367432E-07 14.057003,36.134999 11.841,36.134999z M63.115001,0L64.000001,0 64.000001,35.983002 63.115001,35.983002z M55.534001,0L56.419002,0 56.419002,35.983002 55.534001,35.983002z M53.859001,0L54.745002,0 54.745002,35.983002 53.859001,35.983002z M46.279002,0L47.164001,0 47.164001,35.983002 46.279002,35.983002z M40.469001,0L41.354001,0 41.354001,35.983002 40.469001,35.983002z M38.599001,0L39.484001,0 39.484001,35.983002 38.599001,35.983002z M37.023001,0L37.909001,0 37.909001,35.983002 37.023001,35.983002z M31.214001,0L32.099001,0 32.099001,35.983002 31.214001,35.983002z M29.440001,0L30.328001,0 30.328001,35.983002 29.440001,35.983002z M21.859001,0L22.745001,0 22.745001,35.983002 21.859001,35.983002z M9.4530029,0L10.339001,0 10.339001,35.983002 9.4530029,35.983002z M7.7789993,0L8.6669998,0 8.6669998,35.983002 7.7789993,35.983002z M5.2190018,0L6.6949997,0 6.6949997,36.134999 5.2190018,36.134999z M1.8720016,0L2.7579994,0 2.7579994,35.983002 1.8720016,35.983002z M0,0L0.88800049,0 0.88800049,35.983002 0,35.983002z"/>
                        <TextBlock TextAlignment="Center">生成条码</TextBlock>
                    </StackPanel>
                </Button>
                <Grid Width="50"/>
            </StackPanel>
        </Grid>
        <StackPanel Grid.Row="1" Margin="120, 0, 100, 120" DataContext="{Binding Order}">
            <StackPanel Orientation="Horizontal" Margin="0, 0, 0, 20">
                <TextBlock FontSize="24" Width="100" VerticalAlignment="Center" Text="条形码"/>
                <TextBox x:Name="productBarCodeTextBox" FontSize="24" Width="400" Text="{Binding Path=Product.BarCode,Mode=TwoWay}" KeyDown="productBarCodeTextBox_KeyDown" TextChanged="productBarCodeTextBox_TextChanged" GotFocus="TextBox_GotFocus"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Margin="0, 0, 0, 20">
                <TextBlock FontSize="24" Width="100" VerticalAlignment="Center" Text="品名"/>
                <TextBox x:Name="productNameTextBox" FontSize="24" Width="400" Text="{Binding Path=Product.Name,Mode=TwoWay}" KeyDown="productNameTextBox_KeyDown" GotFocus="TextBox_GotFocus"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Margin="0, 0, 0, 20">
                <TextBlock FontSize="24" Width="100" VerticalAlignment="Center" Text="销售单价"/>
                <TextBox x:Name="productUnitPriceTextBox" FontSize="24" Width="200" Text="{Binding Path=Product.UnitPrice,Mode=TwoWay,Converter={StaticResource DecimalToStringConverter},ConverterParameter=F2}" KeyDown="productUnitPriceTextBox_KeyDown" GotFocus="TextBox_GotFocus"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Margin="0, 0, 0, 20">
                <TextBlock FontSize="24" Width="100" VerticalAlignment="Center" Text="进货单价"/>
                <TextBox x:Name="orderUnitPriceTextBox" FontSize="24" Width="200" Text="{Binding Path=UnitPrice,Mode=TwoWay,Converter={StaticResource DecimalToStringConverter},ConverterParameter=F2}" KeyDown="orderUnitPriceTextBox_KeyDown" GotFocus="TextBox_GotFocus"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Margin="0, 0, 0, 20">
                <TextBlock FontSize="24" Width="100" VerticalAlignment="Center" Text="数量"/>
                <TextBox x:Name="orderCountTextBox" FontSize="24" Width="200" Text="{Binding Path=Count,Mode=TwoWay,Converter={StaticResource DecimalToStringConverter},ConverterParameter=F0}" KeyDown="orderCountTextBox_KeyDown" GotFocus="TextBox_GotFocus"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Margin="0, 0, 0, 20">
                <TextBlock FontSize="24" Width="100" VerticalAlignment="Center" Text="进货总价"/>
                <TextBox x:Name="orderTotalPriceTextBox" FontSize="24" Width="200" Text="{Binding Path=TotalPrice,Mode=TwoWay,Converter={StaticResource DecimalToStringConverter},ConverterParameter=F2}" KeyDown="orderTotalPriceTextBox_KeyDown" GotFocus="TextBox_GotFocus"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Margin="0, 0, 0, 20">
                <Button x:Name="saveButton" Style="{StaticResource SaveAppBarButtonStyle}" Click="saveButton_Click"/>
                <Button Style="{StaticResource DiscardAppBarButtonStyle}" Click="discardButton_Click"/>
            </StackPanel>
        </StackPanel>
    </Grid>
</common:LayoutAwarePage>
